﻿#ifndef _FITK_ACOUSTICS_MATERIAL_MGR_ADAPTOR_H___
#define _FITK_ACOUSTICS_MATERIAL_MGR_ADAPTOR_H___
 
#include "FITKAcousticsAbstractAdaptor.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsAbsMaterial.h"
#include "FITK_Component/FITKAcousticsPhysics/FITKAcousticsMaterialsFluid.h"
#include <H5Cpp.h>

namespace IO {
    class FITKHDF5FileTool;
    class FITKAcousticsAbsMaterial;
}

namespace IO
{
    class FITKAcousticsHDF5IOAPI FITKAcousticsMaterialMgrAdaptor : public FITKAcousticsAbsAdaptor
    {
    public:
        explicit FITKAcousticsMaterialMgrAdaptor() = default;
        virtual ~FITKAcousticsMaterialMgrAdaptor() = default;

        virtual bool adaptR() override;

        virtual bool adaptW() override;

    private:
        /**
        * @brief 写流体数据到hdf5
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  Fluids        流体材料数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-23
        */
        bool writeFluidMaterials(H5::Group &MaterialGroup, QList<Acoustics::FITKAcousticsAbsMaterial*>Fluids);


        /**
        * @brief 写粘弹性数据到hdf5
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  ViscoElastics        粘弹性材料数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-23
        */
        bool writeViscoElastics(H5::Group &MaterialGroup, QList<Acoustics::FITKAcousticsAbsMaterial*>ViscoElastics);
           

        /**
        * @brief 写各向同性数据到hdf5
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  IsotropicSolids        各向同性数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-23
        */
        bool writeIsotropicSolids(H5::Group & MaterialGroup, QList<Acoustics::FITKAcousticsAbsMaterial*>IsotropicSolids);


        /**
        * @brief 写泡沐数据到hdf5
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  Foams        泡沐材料数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-23
        */
        bool writeFoam(H5::Group & MaterialGroup, QList<Acoustics::FITKAcousticsAbsMaterial*>Foams);



        /**
        * @brief 写纤维数据到hdf5
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  Fibers      纤维数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-25
        */
        bool writeFibers(H5::Group & MaterialGroup, QList<Acoustics::FITKAcousticsAbsMaterial*>Fibers);



        /**
        * @brief 写PE数据到hdf5
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  FEMaterial      PE数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-25
        */
        bool writeFEMaterial(H5::Group & MaterialGroup, QList<Acoustics::FITKAcousticsAbsMaterial*>FEMaterial);



        /**
        * @brief 读流体文件到数据仓库
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  mager材料管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-23
        */
        bool readFluidMaterials(H5::Group &MaterialGroup, Acoustics::FITKAcousticsMaterialManager*mager);



        /**
        * @brief 读各向同性文件数据到数据仓库
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  mager材料管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-24
        */
        bool readIsotropicSolids(H5::Group &MaterialGroup, Acoustics::FITKAcousticsMaterialManager*mager);

        /**
        * @brief 读粘弹性数据文件数据到数据仓库
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  mager材料管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-24
        */
        bool readViscoElasticss(H5::Group &MaterialGroup, Acoustics::FITKAcousticsMaterialManager*mager);

        /**
        * @brief 读泡沐数据文件数据到数据仓库
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  mager材料管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-24
        */
        bool readFoam(H5::Group &MaterialGroup, Acoustics::FITKAcousticsMaterialManager*mager);


        /**
        * @brief 读纤维数据文件数据到数据仓库
        * @param @param[i]  MaterialGroup hdf5组别
        * @param @param[i]  mager材料管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-25
        */
        bool readFiber(H5::Group &MaterialGroup, Acoustics::FITKAcousticsMaterialManager*mager);

        /**
        * @brief 判断是否全部为true
        * @param @param[i]  Data 数组
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-19
        */
        bool areAllTrue(const std::vector<bool>& Data);


        /**
        * @brief检查是否含有特殊字符，没有则直接返回，有则转换
        * @param @param[i]  data 检查的字符串
        * @author yangjing (1195810980@qq.com)
        * @date 2024-12-19
        */
        QString RestoreStr(std::string data);




        /**
        * @brief 将FluidType枚举转换为str
        * @param @param[i]  type 类型
        * @author yangjing (1195810980@qq.com)
        * @date 2025-1-2
        */
        QString FluidTypeToStr(Acoustics::FITKAcousticsMaterialsFluid::FluidType type);

        /**
        * @brief 将str转换为FluidType枚举
        * @param @param[i]  type 类型
        * @author yangjing (1195810980@qq.com)
        * @date 2025-1-2
        */
        Acoustics::FITKAcousticsMaterialsFluid::FluidType StrFromFluidType(QString type);

    private:
        IO::FITKHDF5FileTool*m_toolp{nullptr};
    };

    Register2FITKIOAdaptorFactory(FITKAcousticsHDF5, Acoustics::FITKAcousticsMaterialManager, FITKAcousticsMaterialMgrAdaptor);

}


#endif
